﻿#include "chnswitch-unit.h"

ChnSwitchUnit::ChnSwitchUnit(int wnd_index, QWidget *parent) : QWidget(parent)
{
    chk_show_ = new QCheckBox(this);
    lab_colstate_ = new QLabel(this);
    comb_chn_ = new QComboBox(this);
    hbox_lay_ = new QHBoxLayout();
    lab_video_ = new QLabel(this);

    hbox_lay_->addWidget(chk_show_);
    hbox_lay_->addWidget(lab_colstate_);
    hbox_lay_->addWidget(comb_chn_);

    chk_show_->setFixedWidth(25);
    lab_colstate_->setFixedWidth(150);
    comb_chn_->setFixedWidth(100);

    comb_chn_->addItem(tr("chn1"));
    comb_chn_->addItem(tr("chn2"));
    comb_chn_->addItem(tr("chn3"));
    comb_chn_->addItem(tr("chn4"));
    comb_chn_->addItem(tr("chn5"));
    comb_chn_->addItem(tr("chn6"));
    comb_chn_->addItem(tr("chn7"));
    comb_chn_->addItem(tr("chn8"));

    connect(comb_chn_, SIGNAL(currentIndexChanged(int)),
            this, SLOT(slot_chan_index_switch(int)));

}

void ChnSwitchUnit::set_col_state(E_COL col_type)
{
    if(COL_RED == col_type) {
        lab_colstate_->setStyleSheet("background-color: red");
    }
    else if(COL_GREEN == col_type) {
        lab_colstate_->setStyleSheet("background-color: green");
    }
    else if(COL_GRAY == col_type) {
        lab_colstate_->setStyleSheet("background-color: gray");
    }
}

void ChnSwitchUnit::slot_chan_index_switch(int index)
{

}

void ChnSwitchUnit::resizeEvent(QResizeEvent *event)
{
    int w = event->size().width();
    int h = event->size().height();
    int layh = 30;
    hbox_lay_->setGeometry(QRect(0,0, w, layh));
    lab_video_->setGeometry(0, layh, w, h-layh);
    event->accept();
}
